#ifndef __SLEEPLOCK_H
#define __SLEEPLOCK_H

#include "type.h"
#include "lock/spinlock.h"

typedef struct sleeplock_t sleeplock_t;

// Long-term locks for processes
struct sleeplock_t {
    uint8_t locked;  // Is the lock held?
    spinlock_t lk;   // spinlock protecting this sleep lock

    // For debugging:
    char* name;  // Name of lock.
    int pid;     // Process holding lock
};

void sleeplock_acquire(sleeplock_t*);
void sleeplock_release(sleeplock_t*);
int sleep_holding(sleeplock_t*);
void sleeplock_init(sleeplock_t*, char*);

#endif
